package com.fs.sys.web;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fs.sys.bean.dto.PhoneMessageDTO;
import com.fs.sys.bean.query.PhoneMessageQuery;
import com.fs.sys.entityservice.PhoneMessageEntityService;
import com.fs.sys.service.KaptchaService;
import com.fs.sys.service.PhoneMessageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.PermitAll;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 短信控制器 
 * @author Coder Generator 2025-06-19 10:08:24 
 **/
@RestController
@RequestMapping("/sys/phone-message")
@Slf4j
@Tag(name = "短信控制器")
public class PhoneMessageController {
    @Autowired
    private PhoneMessageEntityService service;

    @Autowired
    private PhoneMessageService phoneMessageService;

    @GetMapping("send")
    @PermitAll
    public void sendVerifyCode(String phone, String imageKey, String imageCode) {
        phoneMessageService.sendVerifyCode(phone, imageKey, imageCode);
    }

    @GetMapping("detail/{id}")
    @Operation(summary = "根据id查找记录")
    public PhoneMessageDTO findById(@PathVariable("id") String id) {
        return service.findById(id).orElse(null);
    }

    @PostMapping("page-query")
    @Operation(summary = "查询-分页")
    public IPage<PhoneMessageDTO> pageQuery(@RequestBody PhoneMessageQuery query) {
        return service.pageQuery(query);
    }

    @PostMapping("query")
    @Operation(summary = "查询-不分页")
    public List<PhoneMessageDTO> query(@RequestBody PhoneMessageQuery query) {
        return service.query(query);
    }
}